<template>
    <div
        class="skill-box"
        :style="{
            borderRadius: `${data.rpxStyle['border-radius']}px`,
        }"
    >
        <div
            class="shop-head cls-between"
            :style="{
                background: `linear-gradient(180deg, ${data.style.start_color}, #fff)`,
            }"
        >
            <div class="shop-head__left cls-flex line-one">
                <span class="shop-head__name" :style="{ color: data.style.head_color }">{{ data.data.skill_name }}</span>
            </div>
            <div class="shop-head__right cls-flex" :style="{ color: data.style.head_color }">
                距开始:<span class="time-item">01</span><em>天</em><span class="time-item">12</span><em>时</em><span class="time-item">24</span><em>分</em
                ><span class="time-item">59</span><em>秒</em>
            </div>
        </div>

        <div class="pdc-one">
            <div class="cls-flex" v-for="(good, gi) in data.data.data" :key="gi" style="padding-bottom: 12px">
                <div class="pdc-one__img">
                    <img :src="good.img" />
                    <!-- 遮罩层 -->
                    <view class="left-two-overlay" v-if="good.sku == 0">已售罄</view>
                </div>
                <div class="cls-column pdc-one__right">
                    <div>
                        <div class="pdc-one__line">
                            <div class="line-one pdc-title" :style="{ fontWeight: data.style.weight }">
                                {{ good.product_name }}
                            </div>
                            <div class="pdc-one__level" :style="{ color: data.style.price_color }" v-if="good.level">{{ good.level }}级</div>
                        </div>
                        <div class="pdc-tip">{{ good.color }}; {{ good.level }}级; {{ good.norm }}/{{ good.unit }}; 剩余:{{ good.sku }}{{ good.unit }}</div>
                        <div class="pdc-tag-list cls-flex" v-if="data.style.showSupp">
                            <div class="padc-tag__supp line-one" v-if="good.supplier">{{ good.supplier.title }}</div>
                            <template v-for="(tag, tag_index) in good.supplier.tag_list" :key="tag.tag_id">
                                <div class="pdc-tag" v-if="tag_index < 3">
                                    {{ tag.title }}
                                </div>
                            </template>
                        </div>
                        <!-- 进度条 -->
                        <div class="pdc-progress" :style="{ background: data.style.proBg }">
                            <div class="pdc-progress__block" :style="{ background: data.style.proColor }">
                                <div class="pdc-progress__pivot" :style="{ background: data.style.proColor }">{{ good.progress || 0 }}%</div>
                            </div>
                        </div>
                    </div>
                    <div class="cls-between" style="align-items: flex-end">
                        <div>
                            <span class="c-green" style="font-size: 12px" :style="{ fontWeight: data.style.weight, color: data.style.price_color }">￥</span>
                            <span class="c-green" style="font-size: 16px" :style="{ fontWeight: data.style.weight, color: data.style.price_color }">{{
                                good.product_price
                            }}</span>
                            <span class="c-grey" style="font-size: 12px">/{{ good.unit }}</span>
                        </div>
                        <div>
                            <span
                                class="foot-btns"
                                :style="{ background: data.style.price_color, borderRadius: data.style.btnRound ? '30px' : '5px' }"
                                v-if="data.style.showBuy"
                                >{{ data.data.btn_name }}
                            </span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="pdc-none cls-center">
                查看更多<el-icon><ArrowRight /></el-icon>
            </div>
        </div>
        <div v-if="!data.data.data.length" class="cls-center cls-column" style="width: 100%; padding-top: 1rem">
            <img
                :src="proxy.imgUrl + 'tenant_593be52a46f869eea8b31d146d21de7a/album/202304/20230413_a14d3c70d6355877771685f19a24abb6.png'"
                style="width: 200px; height: auto"
            />
            <div class="none-text">暂无商品</div>
        </div>
    </div>
</template>

<script setup>
import { getCurrentInstance } from "vue"
import { ArrowRight } from "@element-plus/icons-vue"

const { proxy } = getCurrentInstance()

/**
 * 秒杀专区，左图右文
 * @property {Object} pageData  页面数据
 */
const props = defineProps({
    data: {
        type: Object,
        default: {
            id: 14,
            type_name: "skill",
            text: "秒杀专区",
            data: {
                skill_name: "限时秒杀",
                btn_name: "立即抢",
                /**请求地址*/
                reqUrl: "",
                /**请求参数*/
                reqData: {},
                /* 当没有请求地址的时候，使用data数据 */
                data: [],
            },
        },
    },
})
</script>

<style lang="less" scoped>
.left-two-overlay {
    z-index: 2;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 15px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    overflow: hidden;
}
.pdc-none {
    height: 40px;
    color: #969799;
    font-size: 12px;
}
.skill-box {
    overflow: hidden;
    padding-bottom: 10px;
    background-color: #fff;
    .shop-head {
        padding: 0px 14px;
        overflow: hidden;
        height: 42px;
        .shop-head__left {
            flex: 1;
            margin-right: 20px;
            .shop-head__name {
                font-weight: bold;
                font-size: 16px;
            }
        }
        .shop-head__right {
            font-size: 12px;
            .time-item {
                display: inline-block;
                width: 22px;
                color: #fff;
                text-align: center;
                background-color: #ee0a24;
                border-radius: 5px;
                line-height: 20px;
            }
            em {
                padding: 0px 2px;
            }
        }
    }
    .pdc-progress {
        width: 100%;
        height: 14px;
        position: relative;
        border-radius: 999px;
        .pdc-progress__block {
            border-radius: inherit;
            width: 0%;
            height: 100%;
            left: 0;
            position: absolute;
            .pdc-progress__pivot {
                border-radius: 999px;
                color: #fff;
                text-align: center;
                min-width: 30px;
                word-break: keep-all;
                padding: 0px 5px;
                font-size: 12px;
            }
        }
    }

    .none-text {
        margin-top: -10px;
        margin-bottom: 30px;
        color: #969799;
    }

    .pdc-one__line {
        width: 100%;
        display: flex;
        align-items: center;
        .pdc-title {
            font-size: 14px;
            color: #323233;
        }
        .pdc-one__level {
            margin-left: 5px;
            font-size: 14px;
            flex: none;
        }
    }

    .pdc-tip {
        font-size: 10px;
        color: #606881;
        padding: 4px 0 3px;
    }

    .foot-btns {
        color: #fff;
        height: 28px;
        line-height: 28px;
        padding: 0px 14px;
        font-size: 12px;
        display: block;
    }
}

.pdc-tag-list {
    margin-bottom: 4px;
    .pdc-tag {
        border-radius: 2px;
        background: #ffeeea;
        padding: 1px 3px;
        font-size: 10px !important;
        color: #fd7047;
        margin-right: 4px;
    }
    .padc-tag__supp {
        font-size: 13px;
        color: #606881;
        margin-right: 3px;
        max-width: 65px;
    }
}

.pdc-one {
    background: #fff;
    padding: 12px 14px 0;
    .pdc-one__img {
        width: 120px;
        height: 120px;
        border-radius: 5px;
        overflow: hidden;
        flex: none;
        position: relative;
        img {
            width: 100%;
            height: 100%;
        }
    }
    .pdc-one__right {
        margin-left: 10px;
        min-height: 120px;
        justify-content: space-between;
        flex: 1;
    }
}
.c-green {
    color: #0ac393;
}

.c-grey {
    color: #606881;
}

.foot-buy {
    width: 24px;
    height: 24px;
}
</style>
